package com.xiaomaoguai.hello;

import org.springframework.context.ApplicationEvent;
import org.springframework.context.event.SmartApplicationListener;
import org.springframework.stereotype.Component;

@Component
public class WangwuListener implements SmartApplicationListener {

	@Override
	public void onApplicationEvent(ApplicationEvent event) {
		System.out.println("王五在孙六之前收到新的内容：" + event.getSource());
	}

	/**
	 * 事件顺序，越小优先级越高
	 */
	@Override
	public int getOrder() {
		return 1;
	}

	/**
	 * 用于指定支持的事件类型，只有支持的才调用onApplicationEvent
	 */
	@Override
	public boolean supportsEventType(Class<? extends ApplicationEvent> eventType) {
		return eventType == ContentEvent.class;
	}

	/**
	 * 支持的目标类型，只有支持的才调用onApplicationEvent
	 */
	@Override
	public boolean supportsSourceType(Class<?> sourceType) {
		return true;
	}

}
